"""
   author: 陈亚敏
   data: 2021/12/14  16:35
   project: 1
"""
import random
class Master():
    def __init__(self,name,sex,cloth):
        self.name=name
        self.sex=sex
        self.cloth=cloth
        self.blood=100
        self.df=(self.cloth==1 and 5 or 10)
        self.room=None
    def battle(self,m2):
        while 1:
            if self.blood == 0 or m2.blood == 0:
                print(f'{self.name}赢了！' or m2.name and self.blood < m2.blood)
                break
            self.blood -= self.df
            print(f'{self.name}被打了,-{self.df}点血！，血量：{self.blood}')
            m2.blood -= m2.df
            print(f'{m2.name}被打了,-{m2.df}点血！，血量：{m2.blood}')


class Room():
    def __init__(self,rnum):
        self.rnum=rnum
        self.fight=[]
    def add(self, mname):
        if mname.room == None:
            if len(self.fight) < 2:
                self.fight.append(mname)
                mname.room = self
                print(f"{mname.name}成功加入{self.rnum}房间")
        else:
            print(f"{mname.name}已加入{mname.room.rnum}房间")

print('''
1.新建人物
2.创建房间
3.加入房间
4.战斗
5.退出
''')
roles = dict()
rooms = dict()
while True:
    enter_number = input("请输入您的操作：\n")
    if enter_number.isdigit():
        enter_number = int(enter_number)
        if enter_number == 1:
            name=input('name:')
            sex=input('sex:')
            cloth=input('cloth:')
            roles[name] = Master(name,sex,cloth)
        elif enter_number == 2:
            room = input("请输入房间的名字：\n")
            rooms[room] = Room(room)
        elif enter_number == 3:
            print(f"当前角色有{roles.keys()}，当前房间有{rooms.keys()}")
            role_name= input("name:")
            room_name = input("room:")
            rooms[room_name].add(roles[role_name])
        elif enter_number == 4:
            rooms[room_name].fight[0].battle(rooms[room_name].fight[1])
        elif enter_number == 5:
            print('886')
            break
    else:
        print("输入有误！请重新输入！")
